package com.cjm.one.log.aop;

import com.cjm.one.log.annition.Logs;
import com.cjm.one.log.utils.IpUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Aspect
@Slf4j
public class SysLogAspect {
//    TODO: 记录日志未完善
    @Around("@annotation(logs)")
    @SneakyThrows
    public Object around(ProceedingJoinPoint point, Logs logs) {
        String className = point.getTarget().getClass().getName();
        String methodName = point.getSignature().getName();
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        String url = request.getRequestURL().toString();
        String ip = IpUtils.getIpAddr(request);

        String name = logs.name();

        return null;
    }

}
